#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<stdlib.h>
#include<sys/wait.h>

int main()
{
    printf("Using execl!");
    pid_t id=fork();
    if(id<0)
    {
        perror("fork");
        return -1;
    }
    else if(id==0)
    {
        printf("I am child process!My pid::%d\n",getpid());
        //ls -a -l
        execlp("ls","ls","-a","-l","-i",NULL);
        sleep(1);
        exit(-1);
    }
    else{
        printf("I am parent process!My pid::%d\n",getpid());
        sleep(2);
        int status=0;
        pid_t ret=waitpid(id,&status,0);
        if(ret<0)
        {
            printf("Waiting failed!\n");
        }
        else{
            printf("Waiting success!ret::%d\n",ret);
        }
    }
    return 0;
}
